package cn.cycleif.enums;

import com.baomidou.mybatisplus.annotation.IEnum;
import com.fasterxml.jackson.annotation.JsonValue;

/**
 * @Date: 25/2/8-18:54
 * @Desc:
 */
public enum CommonStatusEnum implements IEnum<Integer> {

  DISABLE(0, "已关闭", "DISABLE"),
  ACTIVE(1, "正常", "ACTIVE"),
  DELETE(2, "已删除", "DELETE"),
  PENDING(3, "审核中", "PENDING");

  private final int    code;
  private final String desc;
  @JsonValue
  private final String sign;

  CommonStatusEnum(int code, String desc, String sign) {
    this.code = code;
    this.desc = desc;
    this.sign = sign;
  }

  public static CommonStatusEnum fromCode(Integer code) {
    for (CommonStatusEnum statusEnum : CommonStatusEnum.values()) {
      if (statusEnum.getValue()
                    .equals(code)) {
        return statusEnum;
      }
    }
    return null;
  }

  @Override
  public Integer getValue() {
    return this.code;
  }
}
